<template>
  <div>
    <!-- 搭建基本布局 -->
    <el-container>
      <el-header>
        XXXX大型后台管理系统
        <dir>
          <div>
            用户名：
            <span>{{username}}</span>
            <el-button @click="logout" type="danger" size="small">退出</el-button>
          </div>
        </dir>
      </el-header>
      <el-container>
        <el-aside width="220px">
          <v-nav></v-nav>
        </el-aside>
        <el-main>
          <!-- 二级路由出口 -->
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import vNav from "../components/vNav.vue";
export default {
    data(){
       return {
           username:''
       }
    },
    mounted(){
       this.username = JSON.parse(sessionStorage.getItem('userinfo')).username
    },
    methods:{
        //退出事件
        logout(){
            this.$store.dispatch('changeUser',false)
            this.$router.push('/login')
        }

        
    },
  components: {
    vNav
  }
};
</script>
<style scoped>
.el-header {
  background-color: green;
}
</style>


